package com.gws.juc;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

class MyThread implements Callable<Integer>{

	@Override
	public Integer call() throws Exception {
		System.out.println("有返回值的线程");
		return 8888;
	}
	
}

/**
 * 第三种实现线程的方式
 * 有返回值的线程
 * @author gws
 *
 */
public class CallableDemo {
	public static void main(String[] args) throws Exception, ExecutionException {
		FutureTask<Integer> futureTask = new FutureTask<Integer>(new MyThread());
		new Thread(futureTask,"A").start();
		Integer result = futureTask.get();
		System.out.println(result);
		
		
	}

}
